package com.secxiot.api.narcotic;

import com.itextpdf.text.DocumentException;
import com.secxiot.common.entity.ResultVo;
import com.secxiot.provider.narcotic.dto.NarcoticPatientDrugsRecordDto;
import com.secxiot.provider.narcotic.entity.NarcoticDocDo;
import com.secxiot.provider.narcotic.entity.NarcoticPatientDrugsRecordDo;
import com.secxiot.provider.narcotic.entity.NarcoticPatientInfoDo;
import com.secxiot.provider.narcotic.entity.TakeDestroyDo;
import com.secxiot.provider.narcotic.vo.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Date;
import java.util.List;

@RequestMapping(value = "/narcotics")
@RestController
public interface NarcoticApi {
    /**
     * 医药须知
     *
     * @param hospitalId 医疗机构ID
     * @param type       类型 数据字典
     * @return 医药须知
     */
    @GetMapping("/narcoticDoc")
    NarcoticDocDo getNarcoticDoc(@RequestParam(value = "hospitalId") Long hospitalId,
                                 @RequestParam(value = "type") String type);

    /**
     * 医药类型
     *
     * @param hospitalId 医疗机构ID
     * @return 医药类型
     */
    @GetMapping("/narcoticDrugs")
    List<NarcoticDrugsVo> selectNarcoticDrugs(@RequestParam(value = "hospitalId") Long hospitalId);

    /**
     * 医药类型
     *
     * @param drugsId 医药类型ID
     * @return 医药类型
     */
    @GetMapping("/getNarcoticDrugsById")
    NarcoticDrugsVo getNarcoticDrugsById(@RequestParam(value = "drugsId") Long drugsId);

    /**
     * 查询用户资料信息
     *
     * @param userId   用户ID
     * @param pageNo   页数
     * @param pageSize 行数
     * @return 用户资料信息
     */
    @GetMapping("/narcoticUserInfo/pageList")
    List<NarcoticPatientInfoVo> selectNarcoticPatientInfoPage(@RequestParam(value = "userId", required = true) Long userId,
                                                              @RequestParam(value = "pageNo", required = true) Integer pageNo,
                                                              @RequestParam(value = "pageSize", required = true) Integer pageSize);

    /**
     * 查询用户资料信息--列表
     *
     * @param userId 用户ID
     * @return 用户资料信息
     */
    @GetMapping("/narcoticUserInfo/list")
    List<NarcoticPatientInfoVo> selectNarcoticPatientInfoList(@RequestParam(value = "userId", required = true) Long userId);

    /**
     * 查询用户资料信息
     *
     * @param patientInfoId 用户资料信息id
     * @return 用户资料信息
     */
    @GetMapping("/narcoticUserInfo/detail")
    NarcoticPatientInfoVo getNarcoticPatientInfoById(@RequestParam(value = "patientInfoId") Long patientInfoId);

    /**
     * 添加用户资料信息
     *
     * @param narcoticPatientInfoVo 资料对象信息
     * @return int
     */
    @PostMapping("/narcoticUserInfo/insert")
    Long insertNarcoticPatientInfo(@RequestBody NarcoticPatientInfoVo narcoticPatientInfoVo) throws IOException, DocumentException;

    /**
     * 修改用户资料信息
     *
     * @param narcoticUserInfoVo 资料对象信息
     * @return int
     */
    @PostMapping("/narcoticUserInfo/update")
    Long updateNarcoticPatientInfo(@RequestBody NarcoticPatientInfoVo narcoticUserInfoVo);

    /**
     * 申请用药信息--列表
     *
     * @param userId     用户ID
     * @param pageNo     页数
     * @param pageSize   条数
     * @param isPage     是否分页  0 否  1 是
     * @param searchName 关键字
     * @return
     */
    @GetMapping("/narcoticDrugsRecord/list")
    List<NarcoticPatientDrugsRecordVo> selectNarcoticPatientDrugsRecord(@RequestParam(value = "userId", required = true) Long userId,
                                                                        @RequestParam(value = "pageNo", required = false) Integer pageNo,
                                                                        @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                                        @RequestParam(value = "isPage", required = true) Integer isPage,
                                                                        @RequestParam(value = "searchName", required = false) String searchName);

    /**
     * 添加申请用药信息
     *
     * @param narcoticPatientDrugsRecordVo 申请用药信息
     * @return int
     */
    @PostMapping("/narcoticDrugsRecord/insert")
    Long insertNarcoticPatientDrugsRecord(@RequestBody NarcoticPatientDrugsRecordVo narcoticPatientDrugsRecordVo);

    /**
     * 修改申请用药信息
     *
     * @param narcoticPatientDrugsRecordVo 申请用药信息
     * @return int
     */
    @PostMapping("/narcoticDrugsRecord/update")
    Long updateNarcoticPatientDrugsRecord(@RequestBody NarcoticPatientDrugsRecordVo narcoticPatientDrugsRecordVo);

    /**
     * 医生药品记录 详情
     *
     * @param doctorRecordId 医生药品记录ID
     * @return
     */
    @GetMapping("/narcoticDoctorRecord/detail")
    NarcoticDoctorRecordVo getNarcoticDoctorRecordById(@RequestParam(value = "doctorRecordId", required = true) Long doctorRecordId);

    /**
     * 医生药品记录 列表
     *
     * @param doctorUserId 医生用户ID
     * @param hospitalId   医疗机构ID
     * @param pageNo       页数
     * @param pageSize     条数
     * @param isPage       是否分页  0 否  1 是
     * @param searchName   关键字
     * @return
     */
    @GetMapping("/narcoticDoctorRecord/list")
    List<NarcoticDoctorRecordVo> selectNarcoticDoctorRecordList(@RequestParam(value = "doctorUserId", required = true) Long doctorUserId,
                                                                @RequestParam(value = "hospitalId", required = true) Long hospitalId,
                                                                @RequestParam(value = "pageNo", required = false) Integer pageNo,
                                                                @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                                @RequestParam(value = "isPage", required = true) Integer isPage,
                                                                @RequestParam(value = "searchName", required = false) String searchName);

    /**
     * 医生药品记录 审核
     *
     * @return
     */
    @PostMapping("/narcoticDoctorRecord/audit")
    ResultVo<NarcoticDoctorRecordVo> auditNarcoticDoctorRecord(@RequestBody NarcoticDoctorRecordVo narcoticDoctorRecordVo);

    @ApiOperation(value = "药师药品记录--详情", httpMethod = "GET")
    @GetMapping("/narcoticChemistRecord/detail")
    NarcoticChemistRecordVo getNarcoticChemistRecordById(@RequestParam(value = "chemistRecordId", required = true) Long chemistRecordId);

    /**
     * 药师药品记录 列表
     *
     * @param chemistUserId 药师用户ID
     * @param hospitalId    医疗机构ID
     * @param pageNo        页数
     * @param pageSize      条数
     * @param isPage        是否分页  0 否  1 是
     * @param searchName    关键字
     * @return
     */
    @ApiOperation(value = "药师药品记录--列表", httpMethod = "GET")
    @GetMapping("/narcoticChemistRecord/list")
    List<NarcoticChemistRecordVo> selectNarcoticChemistRecordList(@RequestParam(value = "chemistUserId", required = true) Long chemistUserId,
                                                                  @RequestParam(value = "hospitalId", required = true) Long hospitalId,
                                                                  @RequestParam(value = "pageNo", required = false) Integer pageNo,
                                                                  @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                                  @RequestParam(value = "isPage", required = true) Integer isPage,
                                                                  @RequestParam(value = "searchName", required = false) String searchName);

    /**
     * 药师药品记录 审核
     *
     * @return
     */
    @ApiOperation(value = "药师药品记录--审核", httpMethod = "POST")
    @PostMapping("/narcoticChemistRecord/audit")
    ResultVo<NarcoticChemistRecordVo> auditNarcoticChemistRecord(@RequestBody NarcoticChemistRecordVo narcoticChemistRecordVo);

    /**
     * 药师重置审核
     *
     * @return
     */
    @ApiOperation(value = "药师重置审核", httpMethod = "POST")
    @PostMapping("/narcoticChemistRecord/resetAudit")
    Long resetAuditNarcoticChemistRecord(@RequestParam("chemistRecordId") Long chemistRecordId,
                                                                      @RequestParam("chemistUserId") Long chemistUserId);
    /**
     * 取药销毁记录 信息
     *
     * @param takeDestroyId 取药记录id
     * @return
     */
    @ApiOperation(value = "取药销毁记录--详情", httpMethod = "GET")
    @GetMapping("/narcoticTakeDestroy/detail")
    NarcoticTakeDestroyVo getNarcoticTakeDestroyById(@RequestParam("takeDestroyId") Long takeDestroyId);

    /**
     * 取药销毁记录 列表
     *
     * @param hospitalId 医疗机构ID
     * @param type       1 取药 2 销毁
     * @param pageNo     页数
     * @param pageSize   条数
     * @param isPage     是否分页  0 否  1 是
     * @param searchName 关键字
     * @return
     */
    @ApiOperation(value = "取药销毁记录--列表", httpMethod = "GET")
    @GetMapping("/narcoticTakeDestroy/list")
    List<NarcoticTakeDestroyVo> selectNarcoticTakeDestroy(@RequestParam("hospitalId") Long hospitalId,
                                                          @RequestParam("type") String type,
                                                          @RequestParam("pageNo") Integer pageNo,
                                                          @RequestParam("pageSize") Integer pageSize,
                                                          @RequestParam("isPage") Integer isPage,
                                                          @RequestParam("searchName") String searchName);

    /**
     *  患者取药
     * @param takeDestroyDo 取药入参
     * @return
     */
    @ApiOperation(value = "取药", httpMethod = "POST")
    @PostMapping("/narcoticTakeDestroy/takeMedicine")
    ResultVo<NarcoticTakeDestroyVo> auditNarcoticTakeMedicine(@RequestBody TakeDestroyDo takeDestroyDo);

    /**
     * 销毁药瓶
     *
     * @param id
     * @param destroyFile   销毁附件
     * @param destroyUserId 销毁人
     * @return
     */
    @ApiOperation(value = "销毁药瓶", httpMethod = "GET")
    @GetMapping("/narcoticTakeDestroy/destoryMedicine")
    ResultVo<NarcoticTakeDestroyVo> auditNarcoticDestroy(@RequestParam("id") Long id,
                                                         @RequestParam("destroyFile") String destroyFile,
                                                         @RequestParam("destroyUserId") Long destroyUserId);

    /**
     * 监管审核资料审核
     *
     * @param narcoticUserInfoVo
     * @return
     */
    @ApiOperation(value = "监管资料--审核", httpMethod = "POST")
    @PostMapping("/narcoticUserInfo/superviseAudit")
    ResultVo<NarcoticPatientInfoVo> auditNarcoticPatientInfo(@RequestBody NarcoticPatientInfoVo narcoticUserInfoVo);

    /**
     * 监管资料列表
     *
     * @param hospitalId 医疗机构ID
     * @param pageNo     页数
     * @param pageSize   条数
     * @param isPage     是否分页  0 否  1 是
     * @return 用户资料信息
     */
    @ApiOperation(value = "监管资料列表--列表", httpMethod = "GET")
    @GetMapping("/narcoticUserInfo/superviseList")
    List<NarcoticPatientInfoVo> selectNarcoticPatientInfoPageByHospital(
            @RequestParam(value = "hospitalId") Long hospitalId,
            @RequestParam(value = "pageNo") Integer pageNo,
            @RequestParam(value = "pageSize") Integer pageSize,
            @RequestParam(value = "isPage") Integer isPage,
            @RequestParam(value = "searchName") String searchName);

    /**
     * 药品跟踪记录--详情
     *
     * @param patientDrugsRecordId 申请用药记录ID
     * @return NarcoticDrugsRecordDo
     */
    @ApiOperation(value = "药品跟踪记录--详情", httpMethod = "GET")
    @GetMapping("/narcoticDrugsRecordDto/detail")
    ResultVo<NarcoticPatientDrugsRecordDto> getNarcoticPatientDrugsRecordDtoById(@RequestParam("patientDrugsRecordId") Long patientDrugsRecordId);

    /**
     * 药品厂家列表
     *
     * @param hospitalId 医院ID
     * @return
     */
    @ApiOperation(value = "药品厂家--列表", httpMethod = "GET")
    @GetMapping("/narcoticDrugsFactory/list")
    List<NarcoticDrugsFactoryVo>  getNarcoticDrugsFactoryList(@RequestParam("hospitalId") Long hospitalId);

    /**
     * 扫码验证药品
     *
     * @param patientDrugsRecordId 申请用药记录Id
     * @param patientUserId 患者用户Id
     * @return
     */
    @ApiOperation(value = "扫码验证药品", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "patientDrugsRecordId", value = "申请用药记录Id", required = true, paramType = "query", dataType = "long"),
            @ApiImplicitParam(name = "patientUserId", value = "患者用户Id", required = true, paramType = "query", dataType = "long"),

    })
    @GetMapping("/scanDrugsQRCode")
    QRCodeProDrugsVo scanDrugsQRCode(@RequestParam("patientDrugsRecordId") Long patientDrugsRecordId,
                                                            @RequestParam("patientUserId") Long patientUserId);

    /**
     * 获取药品统计数据
     *
     * @param userId   用户ID
     * @param dateTime 时间节点
     * @return
     */
    @ApiOperation(value = "获取药品统计数据", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query", dataType = "long"),
            @ApiImplicitParam(name = "dateTime", value = "时间节点", required = true, paramType = "query", dataType = "Date"),
    })
    @GetMapping("/getDrugsCountResultVo")
    public DrugsCountResultVo getDrugsCountResultVo(@RequestParam("userId") Long userId, @RequestParam("dateTime") Date dateTime);

    /**
     * 获取用户有效资料
     *
     * @param userId 用户Id
     */
    @ApiOperation(value = "获取用户有效资料", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query", dataType = "long"),
    })
    @GetMapping("/getPatientInfoByUserId")
    public List<NarcoticPatientInfoVo> getPatientInfoByUserId(@RequestParam("userId") Long userId);

    /**
     * 获取用户未完成的用药申请列表
     *
     * @param userId 用户Id
     */
    @ApiOperation(value = "获取用户未完成的用药申请列表", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query", dataType = "long"),
    })
    @GetMapping("/getPatientDrugsRecordByUserId")
    public List<NarcoticPatientDrugsRecordVo> getPatientDrugsRecordByUserId(@RequestParam("userId") Long userId);
}
